package com.tizona.entity;

import com.tizona.entity.tarification.Accumulator;
import com.tizona.entity.tarification.Parameter;

import java.util.Set;
import java.util.Map;
import java.util.Hashtable;
import java.util.HashSet;

/**
 * Created by Vitaliy Kim.
 * Date: 23.08.2005
 * Time: 19:02:12
 */
public class Se {

    /** identifier field */
    private Long seId;

    /** persistent field */
    private String login;

    /** persistent field */
    private String password;

    /** persistent field */
    private short groupn;

    /** nullable persistent field */
    private String note;

    /** persistent field */
    private boolean adm;

    /** persistent field */
    private boolean main;

    /** persistent field */
    private boolean auto;

    /** persistent field */
    private short activity;

    /** persistent field */
    private boolean admOvr;

    /** persistent field */
    private boolean noPasswd;

    /** persistent field */
    private boolean sepPasswd;

    /** persistent field */
    private Set <Session> sessionDetails = new HashSet<Session>();

    /** persistent field */
    private boolean deleted;

    private boolean updated = false;

    /** nullable persistent field */
    private String profile;

    /** nullable persistent field */
    private Integer lastStart;

    private Lc lc;

    /** persistent field */
    private Long svc;


    /** persistent field */
    private Map<String, Parameter> seProps = new Hashtable<String,com.tizona.entity.tarification.Parameter>();

    /** persistent field */
    private Map <String, Accumulator> seAccums = new Hashtable <String,Accumulator>();

    private Long tarif;

    private Long quote;

    private HashSet<Payment> pays = new HashSet<Payment>();

    public Set <Session> getSessionDetails() {
        return sessionDetails;
    }

    public void setSessionDetails(Set <Session> sessionDetails) {
        this.sessionDetails = sessionDetails;
    }

    /*Default constructor*/
    public Se() {
    }

    public Se(Long seId, boolean auto, short activity, Long svc, Long tarif, Long quote) {
        this.seId = seId;
        this.auto = auto;
        this.activity = activity;
        this.svc = svc;
        this.tarif = tarif;
        this.quote = quote;
    }

    public Long getSeId() {
        return seId;
    }

    public void setSeId(Long seId) {
        this.seId = seId;
    }

    public boolean isAdm() {
        return adm;
    }

    public void setAdm(boolean adm) {
        this.adm = adm;
    }

    public boolean isMain() {
        return main;
    }

    public void setMain(boolean main) {
        this.main = main;
    }

    public boolean isAuto() {
        return auto;
    }

    public void setAuto(boolean auto) {
        if(this.auto != auto) setUpdated(true);
        this.auto = auto;
    }

    public short getActivity() {
        return activity;
    }

    public void setActivity(short activity) {
        if(this.activity != activity) setUpdated(true);
        this.activity = activity;
    }

    public boolean isAdmOvr() {
        return admOvr;
    }

    public void setAdmOvr(boolean admOvr) {
        this.admOvr = admOvr;
    }

    public boolean isDeleted() {
        return deleted;
    }

    public void setDeleted(boolean deleted) {
        this.deleted = deleted;
    }

    public Long getSvc() {
        return svc;
    }

    public void setSvc(Long svc) {
        this.svc = svc;
    }

    public Long getTarif() {
        return tarif;
    }

    public void setTarif(Long tarif) {
        this.tarif = tarif;
    }

    public Long getQuote() {
        return quote;
    }

    public void setQuote(Long quote) {
        this.quote = quote;
    }

    public Lc getLc() {
        return lc;
    }

    public void setLc(Lc lc) {
        this.lc = lc;
    }

    public Map<String, Parameter> getSeProps() {
        return seProps;
    }

    public void setSeProps(Map<String, Parameter> seProps) {
        this.seProps = seProps;
    }

    public Map<String, Accumulator> getSeAccums() {
        return seAccums;
    }

    public void setSeAccums(Map<String, com.tizona.entity.tarification.Accumulator> seAccums) {
        this.seAccums = seAccums;
    }

    /**
     * Change permission on SE
     * @return dummy
     */
    public boolean isUpdated() {
        return updated;
    }

    public void setUpdated(boolean updated) {
        this.updated = updated;
    }

    public HashSet<Payment> getPays() {
        return pays;
    }

    public void setPays(HashSet<Payment> pays) {
        this.pays = pays;
    }

    public com.tizona.entity.tarification.Parameter getParameter(String s)
    {
        return (this.getLc().getLcProps().get(s) != null) ?
                this.getLc().getLcProps().get(s) : this.getSeProps().get(s);
    }


    public static int BGW = 0;
    public static int DIALUP = 1;
    public static int LEASED = 2;
    public static int SUBNET = 3;
    public static int EMAIL = 101;
    public static int HOSTING = 102;
    public static int NNEWS = 103;
    public static int SMS = 999;

}
